﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Newtonsoft.Json;
using System.Collections.Generic;
using Ccit.Utils;

namespace Ccit.OA.NewsCenter
{
    public partial class news_window_frame : Ccit.Utils.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack){
                _hidTabId.Value =(null != Request.QueryString["TABID"]) ? Request.QueryString["TABID"].ToString() : "";

                _hidPlateId.Value = (null != Request.QueryString["plateId"]) ? Request.QueryString["plateId"].ToString() : "";
                _hidType.Value = (null!=Request.QueryString["Type"]) ? Request.QueryString["Type"].ToString() : "0";
            }
            string sPageParamAttr = "plateId="+_hidPlateId.Value+"&Type="+_hidType.Value;
            string encodeParamAttr = base64encode(sPageParamAttr);
            iFrmEditAttr.Attributes["src"] = "news_window_attr.aspx?" + encodeParamAttr;
            string sPageParamQuery = "Oper=1&Type=" + _hidType.Value + "&clauseId=" + _hidPlateId.Value; //Oper=1 操作页面 0：默认 设置窗口选择页面
            string encodeParamQuery = base64encode(sPageParamQuery);
            iFrmEditQuerySet.Attributes["src"] = "news_queryset_edit.aspx?" + encodeParamQuery;
        }

        private string base64encode(string sPageParam)
        {
            string encodeParam = string.Empty;
            if (string.IsNullOrEmpty(sPageParam)) return encodeParam;

            encodeParam = Base64Lib.Encode(sPageParam);
            return encodeParam;
        }

        #region  Ajax Methods
         /// <summary>
         /// 保存
         /// </summary>
         /// <param name="jsonExpr"></param>
         /// <param name="ClauseXml"></param>
         /// <param name="OperSign"></param>
         /// <returns></returns>
        [global::System.Web.Services.WebMethod]
        public static string SaveWinClause(string jsonWin,string jsonClause,string OperSign,string Type)
        {
            MsWinStyle winObj = (MsWinStyle)JavaScriptConvert.DeserializeObject(jsonWin, typeof(MsWinStyle));
            MsQueryClause clauseObj = (MsQueryClause)JavaScriptConvert.DeserializeObject(jsonClause, typeof(MsQueryClause));
            WindowBLL bll=new WindowBLL();
            List<string> strlist = bll.SaveWinStyle(winObj, clauseObj,Type);
            var oResult = new { resFlag=strlist[0],resMes=strlist[1],resPlateId=strlist[2] };
            return JavaScriptConvert.SerializeObject(oResult) + "_" + OperSign;
        }

        #endregion

    }
}
